package com.shanzmoo.db.logistics.entity.vo;

import com.alibaba.fastjson.JSON;
import com.baomidou.mybatisplus.annotation.IdType;
import com.baomidou.mybatisplus.annotation.TableId;
import com.shanzmoo.db.logistics.entity.DeliverySkuDetailEntity;
import io.swagger.annotations.ApiModel;
import lombok.*;

import java.io.Serializable;

/**
 * <p>
 * 发货单商品明细
 * </p>
 *
 * @author Gzhao
 * @since 2020-12-16
 */
@Data
@ApiModel("发货订单详情")
public class DeliverySkuDetailVO implements Serializable {

    private static final long serialVersionUID = 1L;

    /**
     * 自增ID
     */
    @TableId(value = "id", type = IdType.AUTO)
    private Integer id;

    /**
     * 发货单id
     */
    private Integer deliveryId;

    /**
     * 商品编码
     */
    private String sku;

    /**
     * 商品名称
     */
    private String skuName;

    /**
     * 规格属性描述
     */
    private String attributeDesc;

    /**
     * 商品数量
     */
    private String skuNumStr;


    public static DeliverySkuDetailVO create(DeliverySkuDetailEntity entity) {
        DeliverySkuDetailVO skuDetailVO = JSON.parseObject(JSON.toJSONString(entity), DeliverySkuDetailVO.class);
        skuDetailVO.setSkuNumStr(entity.getSkuNum() + " " + entity.getUnit());
        return skuDetailVO;
    }
}
